package name.marz.to.go.ahg.saison.executer;

import java.net.URI;

import name.marz.to.go.ahg.common.util.HttpUtil;
import name.marz.to.go.ahg.core.AutoGetterHttpClient;
import name.marz.to.go.ahg.core.executer.DocumentGetExecuter;

import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

public class SaisonDealDetailExecuter extends DocumentGetExecuter {
	public SaisonDealDetailExecuter(URI uri, AutoGetterHttpClient client, Document dealDoc) {
		super(uri, client,"利用明細確認");
		super.charset = "UTF-8";
		Elements e = dealDoc.getElementsByAttributeValue("alt", "利用明細確認");
		if ( e.size() == 0 ) throw new IllegalStateException("利用明細確認のURLが見つかりません");
		Element a = e.first().parent();
		super.uri = HttpUtil.createURISafety(uri.getScheme(), uri.getAuthority()
						, a.attr("href")
					);
	}
}